﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true"
  CodeBehind="PurchaseList.aspx.cs" Inherits="SaleManagement.Web.Pages.PurchaseList"
  Title="" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div id="divContent" runat="server">
    <table width="100%">
      <tr>
        <td class="search_header">
          Danh sách hóa đơn mua hàng
        </td>
      </tr>
      <tr>
        <td class="formInfo">
          <table border="0" width="100%">
            <tr>
              <td>
                Mã khách hàng:
              </td>
              <td>
                <dxe:ASPxTextBox ID="txtCustomerCode" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" Width="150px">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxTextBox>
              </td>
              <td>
                Tên khách hàng:
              </td>
              <td>
                <dxe:ASPxTextBox ID="txtCustomerName" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" Width="150px">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxTextBox>
              </td>
              <td>
                Điện thoại:
              </td>
              <td>
                <dxe:ASPxTextBox ID="txtCustomerPhone" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" Width="150px">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxTextBox>
              </td>
            </tr>
            <tr>
              <td>
                Mã hóa đơn:
              </td>
              <td>
                <dxe:ASPxTextBox ID="txtPurchaseCode" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" Width="150px">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxTextBox>
              </td>
              <td>
                Từ ngày:
              </td>
              <td>
                <dxe:ASPxDateEdit ID="deFromDate" ClientInstanceName="deFromDate" runat="server"
                  CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
                  ShowShadow="False" Width="150px">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                  <DropDownButton>
                    <Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
                      UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png"
                      Width="9px" />
                  </DropDownButton>
                  <CalendarProperties>
                    <HeaderStyle Spacing="1px" />
                    <FooterStyle Spacing="17px" />
                  </CalendarProperties>
                </dxe:ASPxDateEdit>
              </td>
              <td>
                Đến ngày:
              </td>
              <td>
                <dxe:ASPxDateEdit ID="deToDate" ClientInstanceName="deToDate" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/" ShowShadow="False" Width="150px">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                  <DropDownButton>
                    <Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
                      UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png"
                      Width="9px" />
                  </DropDownButton>
                  <CalendarProperties>
                    <HeaderStyle Spacing="1px" />
                    <FooterStyle Spacing="17px" />
                  </CalendarProperties>
                </dxe:ASPxDateEdit>
              </td>
            </tr>
            <tr>
              <td colspan="6" style="padding: 10px 0 10px 0;" align="center">
                <dxe:ASPxButton ID="btnSearch" runat="server" Text="Tìm" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" AutoPostBack="False">
                  <Image Url="~/Images/find.png" />
                  <ClientSideEvents Click="function(s, e) {
                                    onBtnSearchClick(s, e);
                                }" />
                </dxe:ASPxButton>
              </td>
            </tr>
            <tr>
              <td colspan="6">
                <dxwgv:ASPxGridView ID="gvPurchase" ClientInstanceName="gvPurchase" runat="server"
                  CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" Width="100%" EnableCallbackCompression="True"
                  AutoGenerateColumns="False" OnCustomCallback="gvPurchase_CustomCallback" OnCustomJSProperties="gvPurchase_CustomJSProperties">
                  <Styles CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua">
                  </Styles>
                  <SettingsBehavior AllowDragDrop="False" AllowGroup="False" AllowSort="False" />
                  <SettingsPager PageSize="20">
                    <AllButton>
                      <Image Height="19px" Width="27px" />
                    </AllButton>
                    <FirstPageButton>
                      <Image Height="19px" Width="23px" />
                    </FirstPageButton>
                    <LastPageButton>
                      <Image Height="19px" Width="23px" />
                    </LastPageButton>
                    <NextPageButton>
                      <Image Height="19px" Width="19px" />
                    </NextPageButton>
                    <PrevPageButton>
                      <Image Height="19px" Width="19px" />
                    </PrevPageButton>
                  </SettingsPager>
                  <Images ImageFolder="~/App_Themes/Aqua/{0}/">
                    <HeaderSortDown Height="5px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortDown.png"
                      Width="7px" />
                    <ExpandedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvExpandedButton.png"
                      Width="15px" />
                    <CollapsedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvCollapsedButton.png"
                      Width="15px" />
                    <HeaderFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilter.png" Width="19px" />
                    <DetailCollapsedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvDetailCollapsedButton.png"
                      Width="15px" />
                    <DetailExpandedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvDetailExpandedButton.png"
                      Width="15px" />
                    <HeaderActiveFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilterActive.png"
                      Width="19px" />
                    <HeaderSortUp Height="5px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortUp.png" Width="7px" />
                    <FilterRowButton Height="13px" Width="13px" />
                    <WindowResizer Height="13px" Url="~/App_Themes/Aqua/GridView/WindowResizer.png" Width="13px" />
                  </Images>
                  <SettingsLoadingPanel Text="" Mode="Disabled" />
                  <StylesEditors>
                    <ProgressBar Height="25px">
                    </ProgressBar>
                  </StylesEditors>
                  <ImagesEditors>
                    <CalendarFastNavPrevYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNPrevYear.png"
                      Width="19px" />
                    <SpinEditLargeIncrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncImage.png"
                      UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png"
                      UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png" Width="7px" />
                    <SpinEditLargeDecrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecImage.png"
                      UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png"
                      UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png" Width="7px" />
                    <SpinEditIncrement Height="6px" Url="~/App_Themes/Aqua/Editors/edtSpinEditIncrementImage.png"
                      UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditIncrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
                      UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
                      Width="7px" />
                    <SpinEditDecrement Height="7px" Url="~/App_Themes/Aqua/Editors/edtSpinEditDecrementImage.png"
                      UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditDecrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
                      UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
                      Width="7px" />
                    <CalendarFastNavNextYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNNextYear.png"
                      Width="19px" />
                    <DropDownEditDropDown Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png"
                      UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png"
                      Width="9px" />
                  </ImagesEditors>
                  <Columns>
                    <dxwgv:GridViewDataTextColumn CellStyle-HorizontalAlign="Center" VisibleIndex="1"
                      Width="40px" Caption="Tác vụ">
                      <DataItemTemplate>
                        <img id="imgDelete" alt="" title="Xóa" src="../Images/delete.png" onclick="deleteDetail('<%#Eval("Id")%>')"
                          style="cursor: pointer" />
                        <img alt="" src="../Images/next.png" title="Chi tiết" onclick='javascript:gotoDetail(<%#Eval("Id")%>)'
                          style="cursor: pointer" />
                      </DataItemTemplate>
                      <HeaderStyle HorizontalAlign="Center" />
                      <CellStyle HorizontalAlign="Center">
                      </CellStyle>
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn UnboundType="String" Caption="Mã hóa đơn" FieldName="PurchaseCode"
                      VisibleIndex="2">
                      <HeaderStyle HorizontalAlign="Center" />
                      <CellStyle HorizontalAlign="Center">
                      </CellStyle>
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Tên khách hàng" FieldName="CustomerName" VisibleIndex="2">
                      <HeaderStyle HorizontalAlign="Center" />
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataDateColumn Caption="Ngày mua hàng" FieldName="Date" VisibleIndex="3">
                      <HeaderStyle HorizontalAlign="Center" />
                      <CellStyle HorizontalAlign="Center">
                      </CellStyle>
                    </dxwgv:GridViewDataDateColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Tổng tiền" FieldName="TotalMoney" VisibleIndex="4">
                      <PropertiesTextEdit DisplayFormatString="#,###,##0">
                      </PropertiesTextEdit>
                      <HeaderStyle HorizontalAlign="Center" />
                      <CellStyle HorizontalAlign="Right">
                      </CellStyle>
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataComboBoxColumn Caption="Trạng thái" FieldName="Status" VisibleIndex="4">
                      <PropertiesComboBox DataSourceID="xdsPurchaseStatus" ValueField='Id' TextField="Name" />
                      <HeaderStyle HorizontalAlign="Center" />
                      <CellStyle HorizontalAlign="Center">
                      </CellStyle>
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Ghi chú" FieldName="Notes" VisibleIndex="5">
                      <HeaderStyle HorizontalAlign="Center" />
                    </dxwgv:GridViewDataTextColumn>
                  </Columns>
                  <ClientSideEvents EndCallback="function(s,e){
	gvPurchase_EndCallback(s,e);
}" />
                </dxwgv:ASPxGridView>
              </td>
            </tr>
            <tr>
              <td colspan="6">
                <dxe:ASPxButton ID="btnAdd" runat="server" Text="Thêm mới" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" ClientInstanceName="btnAdd">
                  <ClientSideEvents Click="function(s, e) {
	                                        onAdd();
	                                        e.processOnServer = false;
                                           }" />
                  <Image Url="../Images/add.png" />
                </dxe:ASPxButton>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
  <asp:XmlDataSource ID="xdsPurchaseStatus" runat="server" DataFile="~/App_Data/Status.vi-VN.xml"
    XPath="Status/PurchaseStatus/Item"></asp:XmlDataSource>

  <script language="javascript" type="text/javascript">
    function onBtnSearchClick(s, e) {
      pcWaiting.Show();
      gvPurchase.PerformCallback('Search');
    }

    function onAdd() {
      document.location.href = "PurchaseInfo.aspx";
    }

    function deleteDetail(id) {
      if (confirm('Bạn có thật sự muốn xóa không?')) {
        pcWaiting.Show();
        gvPurchase.PerformCallback('Delete|' + id);
      }
    }

    function gvPurchase_EndCallback(s, e) {
      pcWaiting.Hide();
      var error = gvPurchase.cpInnerError;
      if (error != '') {
        alert(error);
      }
    }

    function gotoDetail(id) {
      window.location.href = 'PurchaseInfo.aspx?id=' + id;
    }
  </script>

</asp:Content>
